home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0292.ZIP / DSI-DCAT.ARC / DSIDCAT.PRG < prev    next >
Text File  |  1985-12-21  |  13KB  |  427 lines

  1. DO WHIL .F.
  2.  
  3.    DSIdCAT.PRG  - Disk Cataloging System in dBASE III (tm)
  4.                   (c) 1984 Darwin Systems, Inc.
  5.  
  6.    AUTHOR:        P. L. Olympia, Ph.D.    -07/15/84-
  7.  
  8.    PURPOSE: 
  9.     Maintains a catalog of disk files and disk names. Disk may be
  10.         either floppy or fixed. All files on the disk, including those
  11.         in subdirectories (up to 9) will be cataloged. Filenames in
  12.         the EXCLUDE file will not be cataloged. The disk directory is
  13.         read via the DOS DIR command and redirected to a scratch disk file.
  14.         If the newly read disk has no label, the program creates a label
  15.         for it using the external program CLIP.COM
  16.  
  17.    SYSTEM FILES:
  18.  
  19.         DSIFILE.DBF indexed on FILE to DSIFILE.NDX
  20.            [Data base of cataloged filenames]
  21.  
  22.         DSIDISK.DBF indexed on DISK to DSIDISK.NDX
  23.        [Data base of cataloged disk names]
  24.  
  25.         DSIXCLUD.DBF indexed on FILE to DSIXCLUD.NDX
  26.            [Data base containing filenames NOT to be cataloged]
  27.  
  28.         DSISCRAT.DBF
  29.        [Scratch data base to hold directory of newly read disk]
  30.  
  31.         DSIDCAT.PRG  - this command file
  32.         DSIREAD.PRG  - Routine that reads a disk
  33.  
  34.         CLIP.COM - external public domain program by W.C. Bodycomb that 
  35.                    puts a volume ID on a disk.
  36.  
  37.     STRUCTURE OF DATA BASES USED:
  38.  
  39.  
  40. Structure for database : C:DSIfile.dbf 
  41. Number of data records :       0       
  42. Date of last update    : 08/05/84      
  43. Field  Field name  Type       Width    
  44.     1  FILE        Character     12    
  45.     2  FBYTES      Numeric        6    
  46.     3  FDATE       Date           8    
  47.     4  FTIME       Character      6    
  48.     5  DISK        Character     23    
  49.     6  FCATEG      Character     30
  50.     7  FDESC       Character     50
  51. ** Total **                     136
  52.  
  53. Structure for database : C:DSIdisk.dbf       
  54.    Number of data records :       0          
  55.    Date of last update    : 08/05/84         
  56. DecField  Field name  Type       Width    Dec
  57.        1  DISK        Character     23       
  58.        2  NUMFILES    Numeric        5       
  59.        3  BYTESFREE   Numeric        7       
  60.        4  BYTESUSED   Numeric        7       
  61.    ** Total **                      43       
  62.  
  63.  
  64. Structure for database : C:DSIxclud.dbf
  65. Number of data records :       2
  66. Date of last update    : 08/05/84
  67. Field  Field name  Type       Width    Dec
  68.     1  FILE        Character     12
  69. ** Total **                      13
  70.  
  71.  
  72. Structure for database : C:DSIscrat.dbf
  73. Number of data records :      13
  74. Date of last update    : 08/01/84
  75. Field  Field name  Type       Width    Dec
  76.     1  FNAME       Character      8
  77.     2  FILL1       Character      1
  78.     3  FTYPE       Character      3
  79.     4  FILL2       Character      3
  80.     5  FBYTES      Character      6
  81.     6  FILL3       Character      2
  82.     7  FDATE       Character      8
  83.     8  FILL4       Character      2
  84.     9  FTIME       Character      6
  85. ** Total **                      40
  86. ENDDO whil F
  87.  
  88. SET TALK OFF
  89. SET SAFE OFF
  90. PUBL mdir,mdisk,bell,msysdrv,msysdate,mopt
  91.  
  92. *        Define global constants
  93.   mdir='D:DIRSCRAT.TXT'
  94.   mdisk='B:            ' 
  95.   bell=CHR(7)
  96.   msysdrv='C'
  97.   msysdate=date()
  98.   mopt='S'
  99.   mrepdest='S'
  100.   mprsc=' '
  101.  
  102. *--------------------- Begin Program --------------------
  103.   CLEA
  104.   TEXT
  105.  
  106.                 WELCOME TO THE DSI DISK CATALOGING SYSTEM
  107.  
  108.    This system will allow you to read and catalog all the filenames
  109.    in a given floppy or fixed disk, including those in a subdirectory.
  110.  
  111.    First, I need to know the drive where all my system files (data bases,
  112.    indices, and programs) reside.
  113.  
  114.    ENDT
  115.    @ 12,0 SAY 'Which drive (A-F) is that? ' GET msysdrv
  116.    READ
  117.    SET DEFA TO &msysdrv
  118.  
  119. SELE 1
  120. USE DSIfile INDE DSIfile
  121. SELE 2
  122. USE DSIdisk INDE DSIdisk
  123. SELE 3
  124. USE DSIxclud INDE DSIxclud
  125. SELE 4
  126. USE DSIscrat
  127. SELE 1
  128.  
  129. DO WHIL .t.
  130.  
  131. CLEA
  132. @ 2,26 SAY "DSI dCAT MAIN MENU            Today:"
  133. @ 2,64 SAY date()
  134. @ 3,0 SAY "-------------------------------------------------------"
  135. @ 3,55 SAY "-----------------"
  136. @ 5,0 SAY "SETUP"
  137. @ 6,2 SAY "S) Set Environment                     Z) Zap/Erase all"
  138. @ 6,58 SAY "catalog entries"
  139. @ 7,2 SAY "V) View/Change report destination"
  140. @ 9,0 SAY "DATA ENTRY/EDIT"
  141. @ 10,2 SAY "A) Add or Read a new disk to catalog   E) Edit a filena"
  142. @ 10,57 SAY "me record"
  143. @ 11,2 SAY "D) Delete/List diskname record(s)      I) Add a filenam"
  144. @ 11,57 SAY "e to the EXCLUDE file"
  145. @ 13,0 SAY "REPORTS"
  146. @ 14,2 SAY "F) Find a filename in the catalog"
  147. @ 15,2 SAY "L) List all files on a given disk"
  148. @ 17,0 SAY "OTHER"
  149. @ 18,2 SAY "H) Help with these choices"
  150. @ 19,2 SAY "X) Exit this program"
  151. @ 21,22 SAY "Please choose a letter ..."
  152. @ 21,51 GET mopt PICT '!'
  153.  
  154. READ
  155. CLEA
  156.  
  157.  DO CASE
  158.  
  159. *-->        Read a new disk to be cataloged
  160.   CASE mopt='A'
  161.     DO dsiread
  162.  
  163. *-->        Delete a diskname record 
  164.   CASE mopt='D'
  165.     more=.t.
  166.     DO WHIL more
  167.        CLEA
  168.        mdiskn=SPACE(18)
  169.        TEXT
  170.  
  171.      At the prompt below, you may give me one of the following:
  172.  
  173.           <diskname> -  the name of the disk to be deleted from the catalog
  174.                         (all files in that disk will also be deleted)
  175.  
  176.                         A blank diskname returns you to the Main Menu 
  177.  
  178.                  L   -  if you want me to give you the list of all known
  179.                         disknames
  180.  
  181.             
  182.         ENDT
  183.  
  184.         @ 15,0 SAY 'Diskname, L or blank ' GET mdiskn
  185.         READ
  186.         mdiskn=UPPER(TRIM(mdiskn))
  187.         IF LEN(mdiskn) = 0
  188.               more=.F.
  189.               LOOP
  190.         ENDIF blank diskname
  191.         SELE 2
  192.         GO TOP
  193.                                        
  194.         IF LEN(mdiskn)=1 .AND. mdiskn='L'
  195.            DO WHIL .NOT. EOF()
  196.               CLEA
  197.               LIST NEXT 21
  198.               WAIT
  199.            ENDDO whil not eof
  200.            LOOP
  201.          ENDIF list disknames
  202.  
  203.          SEEK mdiskn
  204.          IF .NOT. EOF()
  205.             mdiskn=TRIM(disk)
  206.             CLEA
  207.             ok='N'
  208.             @ 12,0 SAY 'Delete disk '+mdiskn+'? (Y/N)' GET ok PICT '!'
  209.             READ
  210. *            ? 'Delete disk '+mdiskn+'? (Y/N)'
  211. *            WAIT TO ok
  212.             IF ok$'yY'
  213.                ? 'Deleting disk '+mdiskn
  214.                DELE
  215.                PACK
  216.                ? 'Deleting filenames of disk '+mdiskn
  217.                SELE 1
  218.                GO TOP
  219.                DELE ALL FOR disk=mdiskn
  220.                PACK
  221.              ENDIF ok
  222.           ELSE
  223.              ? bell+mdiskn+' not in catalog'
  224.           ENDIF diskname in catalog
  225.  
  226.           WAIT 'Delete another diskname (Y/N)? ' TO ok
  227.           STOR ok$'yY' TO more
  228.         ENDDO whil more
  229.         SELE 1
  230.   
  231. *-->        Edit a filename record
  232.        CASE mopt='E'
  233.           mfilen=SPACE(12)
  234.           CLEA
  235.           @ 1,10 SAY 'EDIT A FILENAME'
  236.           @ 10,0 SAY 'Full name or first few letters of file to edit ' ;
  237.             GET mfilen
  238.           READ
  239.           mfilen=UPPER(TRIM(mfilen))
  240.           GO TOP
  241.           SEEK mfilen
  242.           IF .NOT. EOF()
  243.              EDIT 
  244.           ELSE
  245.              ? bell+mfilen+' is not in the catalog'
  246.              WAIT
  247.           ENDIF filename found
  248.  
  249. *-->        Add filename to EXCLUDE FILE
  250.        CASE mopt='I'
  251.           SELE 3
  252.           APPE
  253.           SELE 1
  254.       
  255.  
  256. *-->        Find a file name
  257.        CASE mopt='F'
  258.       SELE 1
  259.       more=.t.
  260.       DO WHIL more
  261.          CLEA
  262.          mfilen=SPACE(12)
  263.              TEXT
  264.                              FIND A FILENAME IN THE CATALOG
  265.  
  266.                 At the next prompt, please specify a unique string in the
  267.                 desired filename. Leave the field blank if you want to exit
  268.                 from this FIND function.
  269.  
  270.  
  271.              ENDT
  272.              @ 10,0 SAY 'Enter filename (blank if done) ' GET mfilen
  273.              READ
  274.          mfilen=UPPER(TRIM(mfilen))
  275. *        Check if filename is blank
  276.              IF LEN(mfilen)=0
  277.                 more=.f.
  278.                 EXIT
  279.              ENDIF blank filename
  280.  
  281. *        List the result
  282. *             LIST FIELDS file,fbytes,fdate,disk FOR '&mfilen'$file
  283.                  REPO FORM DSIfile FOR '&mfilen'$file &mprsc
  284.           IF mprsc=' '
  285.             WAIT
  286.           ENDIF mprsc
  287.           ENDDO whil more
  288.  
  289. *-->        List files on given disk
  290.        CASE mopt='L'
  291.             SELE 1
  292.             more=.t.
  293.             DO WHIL more
  294.                CLEA
  295.                mdiskn=SPACE(23)
  296.                @ 1,10 SAY 'LIST FILES ON SPECIFIED DISK'
  297.            @ 10,0 SAY 'Enter name of disk (blank if done) ' GET mdiskn
  298.                READ
  299.                mdiskn=UPPER(TRIM(mdiskn))
  300.                IF LEN(mdiskn)=0
  301.                   more=.f.
  302.                   EXIT
  303.                ENDIF blank diskname
  304. *               LIST FIELD file,fbytes,fdate,disk FOR disk=mdiskn
  305.                 REPO FORM DSIfile FOR disk=mdiskn &mprsc
  306.                IF mprsc=' '
  307.                   WAIT
  308.                ENDIF mprsc
  309.              ENDDO whil more
  310.  
  311. *-->        Help message
  312.        CASE mopt='H'
  313.             TEXT
  314.                               EXPLANATION OF CHOICES
  315.  
  316.        S - Set environment. Allows you to specify which drive to use to
  317.            read a disk to be cataloged (Default=B:), and the name of the
  318.            file to use as a scratch file for the disk directory (default
  319.            is D:DIRSCRAT.TXT)
  320.  
  321.        V - View or change report destination to either printer or screen.
  322.            Default is screen.
  323.  
  324.        Z - Zap catalog. Erases all entries in the DSIFILE and DSIDISK
  325.            data bases so you can start with a clean slate. Requires
  326.            confirmation because of potential for disaster.
  327.  
  328.        A - Add new disk to catalog. This is the heart of the program. Reads
  329.            the root and subdirectory entries of a disk, and loads data to
  330.            DSIFILE (filenames) and DSIDISK (disknames)
  331.  
  332.        E - Edit filename record. Allows you to edit a filename record
  333.            including category & description fields. Requires that you
  334.            supply a filename identifier.
  335.  
  336.     ENDT
  337.     WAIT
  338.     CLEA
  339.      TEXT
  340.  
  341.        D - Delete/List diskname record. Allows you to list all disknames
  342.            that have been cataloged, and delete any one. If you delete
  343.            a diskname, all filenames belonging to that diskname will also
  344.            be flushed from the catalog.
  345.  
  346.        I - Add filename to the EXCLUDE file. Files in the EXCLUDE file
  347.            (e.g., COMMAND.COM) will not be cataloged when found on a
  348.            disk.
  349.  
  350.        F - Find file in catalog. Gives you information about a file that
  351.            you're interested in. You need to supply a unique substring that
  352.            appears in the desired filename.
  353.  
  354.        L - List files on a given disk. Shows filenames and related info
  355.            of all files on a specified disk
  356.  
  357.        H - Help. This note.
  358.  
  359.        X - Exit. Closes all files and returns you to dBASE III prompt.
  360.  
  361.    ENDT 
  362.             WAIT
  363.       
  364. *-->        Exit program
  365.        CASE mopt='X'
  366.             CLEA ALL
  367.             CANCEL
  368.    
  369. *-->        Printer or Screen
  370.        CASE mopt='V'
  371.             CLEA
  372.             @ 1,10 SAY 'Specify Destination of Report'
  373.             @ 10,0 SAY 'Enter P(rinter) or S(creen)' GET mrepdest PICT '!'
  374.             READ
  375.             IF mrepdest='P'
  376.                mprsc='TO PRIN NOEJ'
  377.             ELSE
  378.                mprsc=' '
  379.             ENDIF printer
  380.  
  381.  
  382. *-->        SetUp Environment
  383.  
  384.        CASE mopt='S'
  385.  
  386. @ 2,23 SAY "dSI dCAT SETUP MENU              Today:"
  387. @ 2,64 SAY date()
  388. @ 3,0 SAY "-------------------------------------------------------"
  389. @ 3,55 SAY "-----------------"
  390. @ 5,0 SAY "Drive where new disk will be mounted (A-D) ........."
  391. @ 5,54 GET mdisk
  392. @ 7,0 SAY "Filename (incl. drive) for directory scratch file .."
  393. @ 7,54 GET mdir
  394. READ
  395.  
  396. *-->        SetUp Environment
  397.        CASE mopt='Z'
  398.  
  399.        TEXT
  400.                            ZAP/ERASE CATALOG ENTRIES
  401.  
  402.         This option allows you to start with a blank slate of databases
  403.         and indices - for example, if you want to maintain more than one
  404.         catalog database (on separate disks).
  405.  
  406.         This will erase all entries in databases DSIFILE and DSIDISK.
  407.  
  408.        ENDT
  409.        ok='N'
  410.        @ 12,0 SAY 'Are you sure you want to ZAP the catalog (Y/N)? ';
  411.            GET ok PICT '!'
  412.        READ
  413.        IF ok='Y'
  414.           SET TALK ON
  415.           SELE 1
  416.           ZAP
  417.           SELE 2
  418.           ZAP
  419.           SELE 1
  420.           SET TALK OFF
  421.         ENDIF ok
  422.  
  423.      ENDC
  424.  
  425.   ENDDO while t
  426.   RETU
  427.